--local newgt = {}                     -- create new environment
--setmetatable(newgt, {__index = _G})
--Characters = newgt                         -- set environment to be name of map
--setfenv(1, newgt)

characters = {}
enemies = {}

characters["hero_f"] = {
  name = "Brynhild",  
  spriteSheet = "data/Sprites/character.png", 
  sizeX = 32,
  sizeY = 32,
  numAnims = 4,
  numFrames = {3, 3, 3, 3},
  class = "Swordsman",
  id = 1
}

characters["walking_guy"] = {
  name = "WalkingGuy",
  spriteSheet = "data/Sprites/rpg_sprite_walk32x64.png",
  sizeX = 48,
  sizeY = 64,
  numAnims = 4,
  numFrames = {8, 8, 8, 8},
  class = "guy",
  id = 200
}

characters["nude_female_elf"] = {
  name = "NudeElf",
  spriteSheet = "data/Sprites/panc_software/elf_female_edit.png",
  sizeX = 48,
  sizeY = 64, 
  numAnims = 8,
  numFrames = {9, 9, 9, 9, 9, 9, 9, 9, 9},
  class = "nudist",
  id = 201
}

function CreateCharacter(name, id, x, y)
  if (characters[name]) then
print(characters[name]);
    CharacterSprite = OForce_Object.Character(x,y,characters[name].sizeX, characters[name].sizeY,
                              characters[name].spriteSheet, characters[name].name, 
                              characters[name].class, characters[name].numAnims,
                              id);
    local i = 1;
    while characters[name].numFrames[i] do 
      CharacterSprite:addAnimFrames(characters[name].numFrames[i]);
      i = i + 1;
    end
    if (characters[name].portrait) then
      CharacterSprite:setPortrait(characters[name].portrait);
    end
    return CharacterSprite;
  else 
print("error adding character")
    return nil;
  end 
end

